import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)
// 解决报错
const originalPush = Router.prototype.push
const originalReplace = Router.prototype.replace
// push
Router.prototype.push = function push (location, onResolve, onReject) {
  if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject)
  return originalPush.call(this, location).catch(err => err)
}
// replace
Router.prototype.replace = function push (location, onResolve, onReject) {
  if (onResolve || onReject) return originalReplace.call(this, location, onResolve, onReject)
  return originalReplace.call(this, location).catch(err => err)
}
const router = new Router({
// 共三个页面： 聊天页面，好友页面，个人简历分别对应一下路由
  routes: [
    // {
    //   path: '/',
    //   name: 'Home',
    //   component: ()=> import('@/components/home/index.vue')
    // },
    {
      path: '/chat',
      name: 'chat',
      component: ()=> import('@/page/chat/chat.vue')
    },
    {
      path: '/friend',
      name:'friend',
      component: ()=> import('@/page/friend/friend.vue')
    },
    {
      path: '/my',
      name:'my',
      component: ()=> import('@/page/resume/resume.vue')
    }
  ],
  linkActiveClass: 'active'
})
// router.push({ path: '/chat' });
export default router
